//
//  JWNewsWebController.m
//  见闻新闻
//
//  Created by brother on 16/3/10.
//  Copyright © 2016年 JoanBoat. All rights reserved.
//

#import "JWNewsWebController.h"
#import "JWNewsModel.h"

@interface JWNewsWebController ()
@property (weak, nonatomic) IBOutlet UIWebView *webView;

@end

@implementation JWNewsWebController

- (void)viewDidLoad {
    [super viewDidLoad];
    UIBarButtonItem *back = [[UIBarButtonItem alloc]initWithTitle:nil style:UIBarButtonItemStylePlain target:self action:@selector(backClick)];
    
    [back setImage:[UIImage imageNamed:@"tabbar_home"]];
    
    self.navigationItem.leftBarButtonItem = back;
    
    
    if (self.newsBlock) {
        JWNewsModel *news = self.newsBlock();
        //NSLog(@"%@",news.body);
        NSString *html = news.body;
        
        NSURL *cssUrl = [[NSBundle mainBundle]URLForResource:@"web" withExtension:@"css"];
        
        html = [NSString stringWithFormat:@"%@<link rel=\"stylesheet\" href=\"%@\">",html,cssUrl];
        
        [self.webView loadHTMLString:html baseURL:nil];
    }
    // Do any additional setup after loading the view from its nib.
}
- (void)backClick {
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
//    
//    self.webView.frame = CGRectMake(0, 64, self.view.frame.size.width, self.view.frame.size.height);
//    [self.view addSubview:self.webView];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
